package com.print.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="USER")
public class User {

	Long idUser;
	String username;
	String password;
	Boolean admin = false;
	Set<UserItem> userItems = new HashSet<UserItem>();
	
	@Id
	@GeneratedValue
	@Column(name="USER_ID")
	public Long getIdUser() {
		return idUser;
	}
	
	public void setIdUser(Long idUser) {
		this.idUser = idUser;
	}
	
	@Column(name="USER_USERNAME")
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name="USER_PASSWORD")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name="USER_ADMIN")
	public Boolean getAdmin() {
		return admin;
	}

	public void setAdmin(Boolean admin) {
		this.admin = admin;
	}
	
	@OneToMany(mappedBy="user", fetch=FetchType.EAGER)
	public Set<UserItem> getUserItems() {
		return userItems;
	}
	
	public void setUserItems(Set<UserItem> userItems) {
		this.userItems = userItems;
	}
	
	public void setUserItems(UserItem userItem) {
		this.userItems.add(userItem);
	}
}